<%-- 
    Document   : addEstimate
    Created on : Dec 15, 2013, 11:57:13 PM
    Author     : toint-lifetek
--%>
<%@page import="java.util.List"%>
<%@page import="com.myapp.bo.WantEsBO"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <tile></tile>
    <body>
        <jsp:include page="/jsp/pages/header.jsp" />
<html:form action="/AddEstimateAction.do" acceptCharset="UTF-8">
    <br/>
    <div class="fieldset">
        <div class="legend">
            Thông tin chung
        </div>
        <table class="tb-border" style="width: 100%;">
            <tr>
                <td class="label-stt">
                    TT
                </td>
                <td class="label">
                    Mã
                </td>
                <td class="label">
                    Nhu cầu
                </td>
                <td class="label">
                    Đơn vị tính
                    
                </td>
                <td class="label">
                    Số người bị ảnh hưởng
                </td>
                <td class="label">
                    Số người cần trợ giúp
                </td>
                <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                    <table class="tb-border" style="padding: 0px; margin: 0px;">
                        <tr>
                            <td colspan="3" class="label" style="text-align: center;">
                                Số lượng cần cứu trợ
                            </td>
                        </tr>
                        <tr>
                            <td class="label-tr-td">
                                Tổng số
                            </td>
                            <td class="label-tr-td">
                                Huy động tại chỗ
                            </td>
                            <td class="label-tr-td">
                                Yêu cầu hỗ trợ
                            </td>
                        </tr>
                    </table>
                </td>
                <td
                <td class="label">
                    Kích cỡ và thông số kỹ thuật
                </td>
                <td class="label">
                    Mức độ ưu tiên(*)
                </td>
            </tr>
            <%
                request.setCharacterEncoding("UTF-8");
                response.setContentType("charset=UTF-8");
                response.setCharacterEncoding("UTF-8");

                List<WantEsBO> lstWant = (List<WantEsBO>) request.getAttribute("lstWant");
                String[] str = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "V", "X", "Y", "Z", "W"};
                int instr = 0;
                int auId = 0;
                for (int i = 0; i < lstWant.size(); i++) {
                    WantEsBO want = lstWant.get(i);
                    if (want.getParentId() == 0) {
            %>
                <tr>
                    <td class="label-stt"><%= str[instr] %><input type="hidden" name="arrWantId" value="<%= want.getWantId() %>" id="arrWantId_<%= auId %>" /></td>
                    <td class="label"><%= want.getCode() == null ? "" : want.getCode() %></td>
                    <td class="label"><%= want.getName() %></td>
                    <td class="label"><input type="text" name="mapUnit(<%= want.getWantId().toString() %>)" id="mapUnit_<%= auId %>" size="10" /></td>
                    <td class="label"><input onkeydown="return isNumberKey(event);"  type="text" name="mapQuantity(<%= want.getWantId().toString() %>)" id="mapQuantity_<%= auId %>" size="10" /></td>
                    <%--<td class="label"><input type="text" name="mapSize(<%= want.getWantId().toString() %>)" id="mapSize_<%= i %>" size="10" /></td>--%>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapPersonHelp(<%= want.getWantId().toString() %>)" id="mapPersonHelp_<%= auId %>" size="10" /></td>
                    <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                        <table class="tb-border" style="padding: 0px; margin: 0px;">
                            <tr>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapTotal(<%= want.getWantId().toString() %>)" id="mapTotal_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapHuyDong(<%= want.getWantId().toString() %>)" id="mapHuyDong_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapYeuCau(<%= want.getWantId().toString() %>)" id="mapYeuCau_<%= auId %>" size="10" /></td>
                            </tr>
                        </table>
                    </td>
                    <td class="label"><input type="text" name="mapKichCo(<%= want.getWantId().toString() %>)" id="mapKichCo_<%= auId %>" size="10" /></td>
                    <td class="label"><input onkeydown="return isNumberKey(event);" type="text" name="mapMucDo(<%= want.getWantId().toString() %>)" id="mapMucDo_<%= auId %>" size="10" /></td>
                </tr>
            <%
                    instr ++;
                    int stt = 1;
                    for (int j = 0; j < lstWant.size(); j++) {
                        WantEsBO wantj = lstWant.get(j);
                        if (wantj.getParentId() != 0 && wantj.getParentId() == want.getWantId()) {
                            auId++;
            %>
                 <tr>
                    <td class="label-stt"><%= stt %><input type="hidden" name="arrWantId" value="<%= wantj.getWantId() %>" id="arrWantId_<%= auId %>" /></td>
                    <td class="label"><%= wantj.getCode() == null ? "" : wantj.getCode() %></td>
                    <td class="label"><%= wantj.getName() %></td>
                    <td class="label"><input type="text" name="mapUnit(<%= wantj.getWantId().toString() %>)" id="mapUnit_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapQuantity(<%= wantj.getWantId().toString() %>)" id="mapQuantity_<%= auId %>" size="10" /></td>
                    <%--<td class="label"><input type="text" name="mapSize(<%= wantj.getWantId().toString() %>)" id="mapSize_<%= i %>" size="10" /></td>--%>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapPersonHelp(<%= wantj.getWantId().toString() %>)" id="mapPersonHelp_<%= auId %>" size="10" /></td>
                    <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                        <table class="tb-border" style="padding: 0px; margin: 0px;">
                            <tr>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapTotal(<%= wantj.getWantId().toString() %>)" id="mapTotal_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapHuyDong(<%= wantj.getWantId().toString() %>)" id="mapHuyDong_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input type="text" onkeydown="return isNumberKey(event);" name="mapYeuCau(<%= wantj.getWantId().toString() %>)" id="mapYeuCau_<%= auId %>" size="10" /></td>
                            </tr>
                        </table>
                    </td>
                    <td class="label"><input type="text" name="mapKichCo(<%= wantj.getWantId().toString() %>)" id="mapKichCo_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapMucDo(<%= wantj.getWantId().toString() %>)" id="mapMucDo_<%= auId %>" size="10" /></td>
                </tr>
            <%
                            stt++;
                            }
                        }
                    auId++;
                    }
                }
            %>
            
            <tr>
                <td colspan="9" style="text-align: center;">
                    <button class="stylish" onclick="return true;" type="submit">
                        <span>Ghi lại</span>
                    </button>
                </td>
            </tr>
        </table>
    </div>
</html:form>
    </body>
</html>